<?php if(!defined('HOST'))die('not access');?>
<style type="text/css">
    body{margin:0px;}  
.line-1{width:100%;height:30px;}
#bg{width:100%;height:100%;top:0px;left:0px;position:absolute;filter: Alpha(opacity=50);opacity:0.5; background:#000000; display:none;}  

</style>
<script>
var c;
$(document).ready(function(){
    {params};
    $("#cqid").val(params.cqid);
    summaryLists_choujiang(params,true);
});
function summaryLists_choujiang(params){

        var a = $('#veiw_{rand}').bootstable({
            tablename:'a_cqzz',celleditor:true,sort:'id',dir:'desc',modedir:'luck|index:cg',params:params,checked:false,fanye:true,
            url:js.getajaxurl('getCqzzLogList','luck|index','cg'),data:params,fanye:true,
            columns:[{
                text:'抽取标题',dataIndex:'title'
            },{
                text:'抽取专家',dataIndex:'name'
            },{
                text:'联系方式',dataIndex:'tel'
            },{
                text:'抽取时间',dataIndex:'addtime'
            },{
                text:'专家类型',dataIndex:'classify_text'
            },{
                text:'当前状态',dataIndex:'type_text'
            },{
                text:'操作',width:300,dataIndex:'id',renderer:function(s,d){
                    if(d.type==1){
                       return '<button onclick="zuofei('+d.id+',1)" class="btn btn-primary btn-xs">作废</button>';
                    }else{
                       return "作废原因："+d.remarks; 
                    }
                    
                }
            }],
            rendertr:function(d){
                var s = '';
               
                return s;
            }
        });
        js.ajax(js.getajaxurl('getZhuanjiaTypeList','luck|index','cg')
                ,{},function(s){
            var content = "<option value=''>-请选择专家类型-</option>";
            var obj=$("select[name='zztype']");
            $.each(s, function(i, field){
                content += "<option value='"+field.id+"' >"+field.name+"</option>";
            });
            if (obj.length>0) {
                obj.html(content);
            }
        },'get,json',false,'');

        c = {
            search:function(){
                var n=$('#name').val();
                var t=$('#title').val();
                var cqid=$('#cqid').val();
                summaryLists_choujiang({name:n,title:t,cqid:cqid},true);
            }
        };
        js.initbtn(c);
}   
</script>
<div>
    <div class="line-1">
     <input  id="cqid" type="hidden" value="" />
        <div class="form-group col-sm-6">
            <div class="row">
                <div class="col-sm-3">
                    <input class="form-control" id="num" name="num" type="text" placeholder="填写抽取数量">
                </div>
                <div class="col-sm-4">
                    <select id="zztype" name="zztype" style="width:100%;" class="form-control">
                        <option value=''>-请选择专家类型-</option> 
                    </select>
                </div>
                <div class="col-sm-4">
                    <button onclick="mergeZhuanjia()"  type="button" clickadd="true" class="btn btn-primary">抽取专家</button>&nbsp;
                </div>
            </div>
        </div>

        <!-- <div class="form-group col-sm-4" style="float:right;">
            <div class="row">
                <div class="col-sm-12">
                    <input style="float:right;margin-left:20px;" class="form-control" id="remarks" placeholder="作废时需要填写作废原因" />
                </div>
            </div>
        </div> -->
        
    </div>
</div>
<div class="blank10"></div>
<div id="veiw_{rand}"></div>



<script>
function mergeZhuanjia(){
    var num = $("#num").val();
    var id  = $("#cqid").val();
    var zztype = $('#zztype option:selected').val(); 
    if(zztype == "" || zztype <1) {
        layer.msg("专家类型不能为空", {icon: 5});
        return ;
    }
    js.ajax(js.getajaxurl('zhixing','luck|index','cg'),{num:num,zztype:zztype,id:id},function(s){ 
            layer.msg(s, {icon: 6});
            {params};
            summaryLists_choujiang(params);
            return ;
            //刷新界面
        },'get,json',false,'');
}
function zuofei(id){
    var zfhtml  = $("#zftanchuan").html();
    console.log(zfhtml);
    layer.open({
        type: 1,
        skin: 'layui-layer-rim', //加上边框
        area: ['350px', '260px'], //宽高
        btn: ['确定', '取消'],
        content: '<div style="width:90%;margin-left:5%;background:#fff;" id="yicang"><div style="text-align:center;"><h3>作废原因</h3></div><div id="log"><input style="float:right;margin-left:20px;" required="required" class="form-control" id="remarks" placeholder="作废时需要填写作废原因" /></div></div>',
        yes : function(){//确定按钮
            var remarks = $("#remarks").val();
            var cqid    = $("#cqid").val();
            if(!remarks || remarks==''){
                layer.msg("请填写作废原因", {icon: 5});return false;
            }
            js.ajax(js.getajaxurl('zuofei','luck|index','cg'),{ remarks:remarks,id:id,cqid:cqid},function(s){
                layer.msg(s, {icon: 6});
                {params};
                summaryLists_choujiang(params);
                parent.layer.closeAll();
                return ;
                //刷新界面
            },'get,json',false,'');
        },
        no : function(){//取消按钮
            layer.close("取消");
        }
    });

    

}

function func7() {
//页面层

}

function couqulog(id){
    // js.ajax(js.getajaxurl('chouqulog','luck|index','cg'),{id:id},function(s){
    //    var data = s;
    //    var content = "<table class='table table-bordered table-hover' style='position:relative;table-layout: fixed;word-break:break-all; word-wrap:break-all;'>";
    //    content += "<thead>";
    //    content += "<tr>";
    //    content += "<th>抽取时间</th>";
    //    content += "<th>抽取专家</th>";
    //    content += "<th>作废原因</th>";
    //    content += "<tr>";
    //    content += "</thead>";
    //    $.each(data, function(i, field){
    //       if(field.remarks){
    //         var remarks = field.remarks;
    //       }else{
    //         var remarks = "";
    //       }
    //       content += "<thead><tr style=''>" +
    //         "<td>"+field.addtime+"</td>" +
    //         "<td>"+field.name+"</td>" +
    //         "<td>"+remarks+"</td>" +
    //         "</tr></thead>";  
    //    });
    //     content += "</table>";
    //    $('#log').html(content);
    //    $("#bg").show();  
    //    $('#yicang').show();
        
    //     //刷新界面
    // },'get,json',false,'');
}
function guanbi(){
    $('#yicang').hide();
    $("#bg").hide();  
    $('#log').html("");
}
</script>